package spring.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;
import org.springframework.web.bind.annotation.SessionAttributes;

@Controller
@RequestMapping("/http")
@SessionAttributes({"name","sex"})
public class HttpController {

    /**
     * 使用解耦的方式:指在控制器中不直接使用HttpServletRequest对象
     * 将数据存入到request对象
     * 在解耦方式下，向Model对象中添加参数，会被Spring的拦截器拦截到
     * 并从Model中将参数取出存入到request对象中
     *
     * @return
     */

    @RequestMapping("/demo1")
    public String demo1(Model model) {
        model.addAttribute("name", "zq");
        model.addAttribute("sex","女");
        return "/test.jsp";

    }
}
